<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>MVVM</title>
    <style>
        .aa{
            color: red;
        }
        .bb{
            background-color: yellow;
        }
    </style>
</head>
<body>
<div id="app">
    <p v-text="msg"></p>
    <p v-html="msg"></p>
    <p class="bb" v-class="myClass">哈哈</p>
</div>
<script src="./mvvm-master/js/observer.js"></script>
<script src="./mvvm-master/js/compile.js"></script>
<script src="./mvvm-master/js/watcher.js"></script>
<script src="./mvvm-master/js/mvvm.js"></script>
<script>
    /**
     * 模版解析: 一般指令解析
     * 1. 得到指令名和指令值(表达式) text/html/class   msg/myClass
     * 2. 从data中根据表达式得到对应的值
     * 3. 根据指令名确定需要操作元素节点的什么属性
     *      v-text ==> textContent属性
     *      v-html ==> innerHtml属性
     *      v-class ==> className属性
     * 4.得到表达式的值 设置到对应的属性上
     * 5 移除元素的指令属性
     *
     */
    const vm = new MVVM({
        el: "#app",
        data: {
            msg: "<a href='https://www.baidu.com'>百度</a>",
            myClass: "aa"
        }
    });

</script>
</body>
</html>